<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>添加学生</title>
    <style>

        body {
            margin: 0;
        }

        h2 {
            text-align: center;
            width: 1000px;
            margin: auto;
            padding-top: 40px;
            padding-bottom: 40px;
        }

        h2 > a {
            float: right;
            font-size: 13px;
        }

        table {
            margin: auto;
            border-collapse: collapse;
        }

        th {
            border: 1px solid black;
            padding: 14px 42px;
        }
        #studentId{
            display: none;
        }
    </style>
</head>
<body>
<h2>修改学生信息</h2>
<form action="/student/updateStudent" method="post">
    <input id="studentId" name="studentId" type="text" value=${Student.studentId}>
    <table>
        <tr>
            <th>姓名：</th>
            <th><input name="name" type="text" value="${Student.name}"></th>
        </tr>
        <tr>
            <th>性别:</th>
            <th>
                    <input id="boy" name="gender"  value="男" type="radio">男
                    <input id="grid" name="gender"  value="女" type="radio">女
            </th>
        </tr>
        <tr>
            <th>年龄:</th>
            <th><input name="age" type="text" value="${Student.age}"></th>
        </tr>
        <tr>
            <th>年级:</th>
            <th>
                <select name="grade" >
                    <option value="学士后">学士后</option>
                    <option value="高中">高中</option>
                    <option value="小学">小学</option>
                    <option value="中学">中学</option>
                </select>
            </th>

        </tr>
        <tr>
            <th>自我介绍:</th>
            <th><textarea name="introduce">${Student.introduce}</textarea></th>
        </tr>
        <tr>
            <th>
                <input type="submit" value="提交">
            </th>
        </tr>
    </table>

</form>

</body>
<script type="text/javascript" charset="utf-8" src="/js/jquery-3.3.1.min.js"></script>
<script type="text/javascript">
    $(function () {
      var code = ${returnDTO == null ? 200:returnDTO.code}

      if(code != 200){
        alert("${returnDTO.msg}");
      }

      var grade = "${Student.grade}";
      $("select").val(grade);

      var gender = "${Student.gender}";
      if (gender == "男"){
        $("#boy").attr("checked","checked");
      }
      if (gender == "女"){
        $("#grid").attr("checked","checked");
      }
    })


</script>
</html>
